-
Notifications
You must be signed in to change notification settings - Fork 4
fix: Fix NotFoundError import mismatch in mock_auth.py #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixed exception import causing mock user creation to fail silently after database wipes. Mock users would not be recreated despite code restart. Problem: - mock_auth.py caught: core.custom_exceptions.NotFoundError - user_repository.py raised: rag_solution.core.exceptions.NotFoundError - Different exception classes = never caught = silent failure - User creation logic never executed due to unhandled exception Solution: - Changed import in mock_auth.py line 16: FROM: from core.custom_exceptions import NotFoundError TO: from rag_solution.core.exceptions import NotFoundError - Now catches the correct exception class Root Cause: - Two exception hierarchies in codebase: 1. core.custom_exceptions.* (older, deprecated) 2. rag_solution.core.exceptions.* (current, actively used) - Repository layer uses rag_solution.core.exceptions - Service layer must use same hierarchy Impact: - Mock user auto-creation now works after database wipes - ensure_mock_user_exists() properly handles user-not-found scenario - Development workflow no longer blocked by missing mock user Files Changed: - backend/core/mock_auth.py (line 16) Testing: - Verified with database wipe + backend restart - Mock user successfully created on startup - No more NotFoundError in logs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🚀 Development Environment OptionsThis repository supports Dev Containers for a consistent development environment. Option 1: GitHub Codespaces (Recommended)Create a cloud-based development environment:
Option 2: VS Code Dev Containers (Local)Use Dev Containers on your local machine:
Option 3: Traditional Local SetupSet up the development environment manually: # Clone the repository
git clone https://github.com/manavgup/rag_modulo.git
cd rag_modulo
git checkout fix/notfounderror-import-mismatch
# Initialize development environment
make dev-init
make dev-build
make dev-up
make dev-validateAvailable CommandsOnce in your development environment: make help # Show all available commands
make dev-validate # Validate environment setup
make test-atomic # Run atomic tests
make test-unit # Run unit tests
make lint # Run lintingServices AvailableWhen running
This automated message helps reviewers quickly set up the development environment. |
PR Review: Fix NotFoundError Import Mismatch in mock_auth.pySummaryThis PR fixes a critical bug where mock user creation was silently failing after database wipes due to an exception import path mismatch. The fix is correct and necessary for proper exception handling alignment. ✅ Code Quality & Best PracticesStrengths
🔍 Potential Issues1. Test Coverage Missing
|
Summary
Fixes mock user creation failure after database wipes by correcting exception import path mismatch between service and repository layers.
Problem
Mock user was not being recreated after database wipes, causing
NotFoundError: User not found: ibm_id=mock-user-ibm-id:mock_auth.pywas catching:core.custom_exceptions.NotFoundErroruser_repository.pywas raising:rag_solution.core.exceptions.NotFoundErrorRoot Cause
Two exception hierarchies exist in codebase:
core.custom_exceptions.*(older, deprecated)rag_solution.core.exceptions.*(current, actively used)Repository layer uses
rag_solution.core.exceptions, but service layer was using the old hierarchy.Solution
backend/core/mock_auth.pyline 16NotFoundErrorclassensure_mock_user_exists()properly handles user-not-found scenarioImpact
Files Changed
backend/core/mock_auth.py(line 16 - import statement)Testing
Type
🤖 Generated with Claude Code